package com.xtayfjpk.spring.security.test.service;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

@Service
public class MyService {

	//@Secured("ROLE_USER")
	@PreAuthorize("hasRole('ROLE_USER')")
	public String getName() {
		Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		System.out.println(principal);
		
		return "zhangsan";
	}
}
